package com.active.service.impl;

import com.active.bean.ActiveTree;
import com.active.dao.ActiveTreeMapper;
import com.active.service.IActiveTreeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class ActiveTreeImpl implements IActiveTreeService {

    @Autowired
    private ActiveTreeMapper activeTreeDao;

    @Override
    @Transactional(readOnly = false)
    public int insertActiveTree(ActiveTree activeTree) throws Exception {
        return activeTreeDao.insert(activeTree);
    }

    @Override
    @Transactional(readOnly = false)
    public int deleteActiveTreeByActiveListId(Integer id) throws Exception {
        return activeTreeDao.deleteByActiveListId(id);
    }

    @Override
    @Transactional(readOnly = true)
    public ActiveTree getNextActiveTree(Integer activeListId, Integer currentTreeId) throws Exception {
        return activeTreeDao.selectNextTree(activeListId,currentTreeId);
    }

    @Override
    @Transactional(readOnly = true)
    public ActiveTree getPrevActiveTree(Integer activeListId, Integer currentTreeId) throws Exception {
        return activeTreeDao.selectPrevTree(activeListId,currentTreeId);
    }

    @Override
    @Transactional(readOnly = false)
    public int deleteByActiveListId(Integer activeListId) throws Exception {
        return activeTreeDao.deleteByActiveListId(activeListId);
    }
}
